package creation_patterns.singleton_pattern.hunger;

/*
 * @Author xuhj
 * @Description 关于instance什么时候会被初始化
 **/
public class HungerSingletonSeri {
    private static HungerSingletonSeri hungerSingleton = new HungerSingletonSeri();
    private HungerSingletonSeri(){}
    public static HungerSingletonSeri getInstance(){
        return hungerSingleton;
    }

    // 加入此方法可以防止序列化创建多个对象，对于程序的健壮性而言比较好
    private Object readResolve(){ return hungerSingleton;}
}
